home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / p063b9s.zip / UNIT / OUTUTIL.PAS < prev    next >
Pascal/Delphi Source File  |  1996-06-30  |  4KB  |  146 lines

  1. UNIT OutUtil;
  2. {╔══════════════════════════════════════════════════════════════════════════╗}
  3. {║ Outbound utilities                            Last changed: 30.06.96  SA ║}
  4. {║                                                                          ║}
  5. {║                         (C) Copyright 1989-96 by                         ║}
  6. {║       Dan Wulff, Jens Sandalgaard, Steen Christensen & S¢ren Ager        ║}
  7. {║                                                                          ║}
  8. {║ This source may not be given to anybody, without the written permission  ║}
  9. {║ from The Portal Team.                                                    ║}
  10. {╚══════════════════════════════════════════════════════════════════════════╝}
  11. {$I POPDEFS.INC}
  12.  
  13. INTERFACE
  14.  
  15. USES Use32, Dos, PoPTypes;
  16.  
  17. CONST
  18.   STypeArray  : Array[1..3] OF String[1] = ('','^','#');
  19.  
  20.   STNothing = 1;
  21.   STDelete  = 2;
  22.   STTrunc   = 3;
  23.  
  24. PROCEDURE SendAFile(CONST FName: PathStr; CONST Address: TFidoAddress; Flavor: Char; Stype: Byte);
  25. FUNCTION  RequestAFile(CONST FName: S12; CONST Address: TFidoAddress; CONST Password: S20): Boolean;
  26. FUNCTION  MakeAPoll(CONST Address: TFidoAddress; Flavor: Char): Boolean ;
  27. FUNCTION  SelectMailType(VAR Escaped : Boolean; HelpTopic: WORD) : Byte;
  28.  
  29. PROCEDURE GlueNode(CONST Address: TFidoAddress);
  30. PROCEDURE UnGlueNode(CONST Address: TFidoAddress);
  31.  
  32. IMPLEMENTATION
  33.  
  34. USES OpString, OpCmd,
  35.      OproUtil, MailUtil, NetFile{FileUtil}, Resource, Globals;
  36.  
  37.   PROCEDURE SendAFile(CONST FName: PathStr; CONST Address: TFidoAddress; Flavor: Char; Stype: Byte);
  38.   VAR
  39.     TempFile : TNetFile;
  40.     s        : String;
  41.     Found    : Boolean;
  42.   BEGIN
  43.     IF TempFile.OpenWithMode(HoldFileName(Address,True)+Flavor+'LO', 1, True, ShareRW+ShareDenyW) THEN
  44.     BEGIN
  45.       Found:=False;
  46.       WHILE NOT Found AND Not TempFile.EoF DO
  47.       BEGIN
  48.         TempFile.ReadLine(s);
  49.         IF (s<>'') AND (s[1] IN ['^','~','#']) THEN Delete(s,1,1);
  50.         Found:=(StUpCase(s)=StUpCase(FName));
  51.       END;
  52.     END;
  53.     IF NOT Found THEN
  54.     BEGIN
  55.       TempFile.Seek(TempFile.FileSize);
  56.       TempFile.WriteLine(STypeArray[SType]+FName);
  57.     END;
  58.     TempFile.Close;
  59.   END;
  60.  
  61.   FUNCTION RequestAFile(CONST FName: S12; CONST Address: TFidoAddress; CONST Password: S20): Boolean;
  62.   VAR
  63.     ReqFile : TNetFile;
  64.     Found   : Boolean;
  65.     s       : String;
  66.   BEGIN
  67.     IF ReqFile.OpenWithMode(HoldFileName(Address,True)+'REQ', 1, True, ShareRW+ShareDenyW) THEN
  68.     BEGIN
  69.       Found:=False;
  70.       WHILE NOT ReqFile.EoF AND NOT Found DO
  71.       BEGIN
  72.         ReqFile.ReadLine(s);
  73.         IF (Length(s)>0) AND (s[1] <> ';') THEN
  74.         BEGIN
  75.           IF Pos(' ',s)>0 THEN s:=Copy(s, 1, Pos(' ',s)-1);
  76.           Found:=StUpCase(s)=StUpCase(FName);
  77.         END;
  78.       END;
  79.       ReqFile.Seek(ReqFile.FileSize);
  80.       IF NOT Found THEN
  81.       BEGIN
  82.         IF Password='' THEN
  83.           ReqFile.WriteLine(FName)
  84.         ELSE
  85.           ReqFile.WriteLine(FName+' !'+Password);
  86.       END;
  87.       ReqFile.Close;
  88.       RequestAFile:=NOT Found;
  89.     END ELSE
  90.       RequestAFile:=False;
  91.   END;
  92.  
  93.   FUNCTION MakeAPoll(CONST Address: TFidoAddress; Flavor: Char): Boolean ;
  94.   VAR
  95.     PollFile : FILE;
  96.   BEGIN
  97.     Assign(PollFile, HoldFileName(Address,True)+Flavor+'LO');
  98.     Reset(PollFile,1);
  99.     IF IOResult=0 THEN
  100.     BEGIN
  101.       MakeAPoll:=False;
  102.     END ELSE
  103.     BEGIN
  104.       Rewrite(PollFile,1);
  105.       MakeAPoll:=True;
  106.     END ;
  107.     Close(PollFile);
  108.   END;
  109.  
  110.   FUNCTION SelectMailType(VAR Escaped: Boolean; HelpTopic: Word): Byte;
  111.   VAR
  112.     m         : TPoPMenu;
  113.     OldTopic,
  114.     LastCmd,
  115.     key       : Word;
  116.   BEGIN
  117.     OldTopic:=Topic;
  118.     Topic:=HelpTopic;
  119.     GetMenu(MnuOMSelMailType,3,m);
  120.     m.ProcessMenu(Key, LastCmd);
  121.     Escaped:=(LastCmd=ccQuit);
  122.     SelectMailType:=Byte(Key);
  123.     Topic:=OldTopic;
  124.   END;
  125.  
  126.   PROCEDURE GlueNode(CONST Address: TFidoAddress);
  127.   VAR
  128.     GlueFile : FILE;
  129.   BEGIN
  130.     Assign(GlueFile, HoldFileName(Address,True)+'GLU');
  131.     ReWrite(GlueFile,1);
  132.     Close(GlueFile);
  133.     IF IOResult<>0 THEN ;
  134.   END;
  135.  
  136.   PROCEDURE UnGlueNode(CONST Address: TFidoAddress);
  137.   VAR
  138.     GlueFile : FILE;
  139.   BEGIN
  140.     Assign(GlueFile, HoldFileName(Address,True)+'GLU');
  141.     Erase(GlueFile);
  142.     IF IOResult<>0 THEN ;
  143.   END;
  144.  
  145. END.
  146.